package
{
	import flash.display.Loader;
	import flash.events.Event;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import flash.utils.ByteArray;

	public class BMPDecoder
	{
		public function BMPDecoder()
		{
		}
		
		/**
		 * 解吗byteArrayTo 回调用
		 * @param bytes:ByteArray
		 * @param callBack:Function(bitdata:BitMapData);
		 * @param source:ByteArray
		 */
		public static function doDecode(bytes:ByteArray,callBack:Function,args:Array):void
		{
			var load:Loader=new Loader();
			var loadcon:LoaderContext=new LoaderContext(false,ApplicationDomain.currentDomain,null);//指定域名	
			
			var onComplete:Function=function(e:Event):void
			{
				
					var data:*=e.currentTarget.content.bitmapData;
					callBack(data,args);
			}
			load.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
			load.loadBytes(bytes,loadcon);
			
		}
		
		private static function onComplete(e:Event):void
		{
			var onComp:Function=function(e:Event):void
			{
				var data:*=e.currentTarget.content.BitmapData;
				//callBack(data,args);
			}
		}
	}
}